package com.zhonghan.recharge.controller;

import java.math.BigDecimal;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhonghan.common.bean.Result;
import com.zhonghan.recharge.pojo.ApplyBuyCardOrder;
import com.zhonghan.recharge.service.ApplyBuyCardOrderService;

/**
 * 申请购油控制层
 * @author zhangceven
 *
 */
@Controller
public class ApplyBuyCardOrderController {
	@Autowired
	private ApplyBuyCardOrderService applyBuyCardOrderService;
	
	@RequestMapping(value="/addApplyBuyCard",method=RequestMethod.POST)
	@ResponseBody
	public Result addApplyBuyCard(HttpServletRequest request,HttpServletResponse response,String name,String telephone,String openId){
		
		Result result = applyBuyCardOrderService.addApplyBuyCardOrder(name,telephone,openId);
		
		return result;
		
	}
	
	/**
	 * 获取申请购油订单
	 * @param request
	 * @param response
	 * @param pageNum
	 * @param pageSize
	 * @param orderStatus
	 * @param id
	 * @param telephone
	 * @param beginTime
	 * @param endTime
	 * @return
	 */
	@RequestMapping(value="/getApplyBuyCardOrder",method=RequestMethod.POST)
	@ResponseBody
	public Result getApplyBuyCardOrder(HttpServletRequest request,HttpServletResponse response,Integer pageNum,Integer pageSize,Integer orderStatus,Integer id,String telephone,
			String beginTime,String endTime){
		
		Result result = applyBuyCardOrderService.getApplyBuyCardOrderByCondition(pageNum,pageSize,id,orderStatus,telephone,beginTime,endTime);
		
		return result;
	}
	
	/**
	 * 更新信息
	 * @param id
	 * @param payAmount
	 * @param donationAmount
	 * @param cardSegment
	 * @param isPay
	 * @param orderStatus
	 * @return
	 */
	@RequestMapping("/applyBuyCardOrder/update")
	@ResponseBody
	public Result updateApplyBuyCardOrder(Integer id,BigDecimal payAmount,BigDecimal donationAmount,String cardSegment,Integer isPay,Integer orderStatus){
		
		Result result = applyBuyCardOrderService.updateApplyBuyCard(id,payAmount,donationAmount,cardSegment,isPay,orderStatus);
		
		return result;
		
	}

}
